home *** CD-ROM | disk | FTP | other *** search
- Path: classic.iinet.com.au!news
- From: ng@mitswa.com.au (John A Ng)
- Newsgroups: comp.lang.c++
- Subject: Re: class declaration
- Date: Thu, 25 Jan 1996 02:09:54 GMT
- Organization: MITS (WA)
- Message-ID: <4e6ngs$f2d@classic.iinet.com.au>
- References: <4dphp6$1bp@noc2.drexel.edu> <4drakm$hnu@grid.direct.ca> <ALUN.CHAMPION.96Jan22114418@g7240065.bridge.bst.bls.com>
- NNTP-Posting-Host: grunge197.nv.iinet.net.au
- X-Newsreader: Forte Free Agent 1.0.82
-
- >: st918h5w@dunx1.ocs.drexel.edu (Jonathan Juniman) wrote:
-
- >:> Is it necessary to do this:
-
- >:> class SomeClass
- >:> {
- >:> public:
- >:> void Somefunction(int SomeParameter);
- >:> }
-
- >:> or is it just as legal to do this:
- >:> class SomeClass
- >:> {
- >:> public:
- >:> void SomeFunction(int);
- >:> }
-
- >:> The latter seems to be the convention, but why does the compiler need to
- >:> know the name of SomeFunction's argument? Isn't it sufficient to know the
- >:> type of Somefunction's argument (namely, int)?
-
-
- The parameter variable name is ignored by the compiler. You can either
- not put anything there, or you can have a (legal) variable name (whether
- the name IS or NOT the same as that actually defined in the body). This
- is is allowed for not so much for documentation as for the convenience
- of being able to copy & paste between body and header declaration.
-
- The typical thing is to leave the variable name in both body and header.
-
- By the way, always remember the semi-colon at the end of the class
- definition... it can cause strange compilation errors!
-
-
-
- >: The following will compile under Turbo C++ 3.00 -- I don't know what
- >: the standard is --
-
- >: class foo
- >: {
- >: public:
- >: void bar (int);
- >: };
-
- >: void foo::bar (int baz)
- >: {
- >: // do someFoobar
- >: ++baz;
- >: }
-
- >: void main (void)
- >: {
- >: foo Chocolate;
- >: Chocolate.bar(10);
- >: }
-
- There is absolutely nothing wrong with the above program -- not even
- style.
- Regards,
-
- John Ng
- ng@mitswa.com.au
- Western Australia
-
-